Merged
Conversation
| <img | ||
| alt="print img" | ||
| ref={imageRef} | ||
| src={image.src} |
Check warning
Code scanning / CodeQL
DOM text reinterpreted as HTML Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 months ago
To fix the issue, we need to sanitize or validate the e.target.value input before it is assigned to widgetValue and subsequently used in the DOM. A good approach is to use a library like DOMPurify to sanitize the input or validate the input to ensure it is a safe URL. This ensures that any potentially harmful content is removed before rendering.
The changes will involve:
- Importing
DOMPurifyfor sanitization. - Sanitizing
e.target.valuein thehandleOnchangeTextBoxfunction before assigning it towidgetValue.
Suggested changeset
2
apps/OpenSign/src/components/pdf/WidgetsValueModal.jsx
| @@ -1,2 +1,3 @@ | ||
| import React, { forwardRef, useEffect, useRef, useState } from "react"; | ||
| import DOMPurify from "dompurify"; | ||
| import ModalUi from "../../primitives/ModalUi"; | ||
| @@ -932,5 +933,6 @@ | ||
| setIsShowValidation(false); | ||
| setWidgetValue(e.target.value); | ||
| const sanitizedValue = DOMPurify.sanitize(e.target.value); | ||
| setWidgetValue(sanitizedValue); | ||
| onChangeInput( | ||
| e.target.value, | ||
| sanitizedValue, | ||
| currWidgetsDetails?.key, |
apps/OpenSign/package.json
Outside changed files
| @@ -54,3 +54,4 @@ | ||
| "web-vitals": "^5.0.1", | ||
| "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz" | ||
| "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz", | ||
| "dompurify": "^3.2.6" | ||
| }, |
This fix introduces these dependencies
| Package | Version | Security advisories |
| dompurify (npm) | 3.2.6 | None |
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.